import 'package:flutter/material.dart';
import 'package:wayofdressing/screens/post_screen.dart';

class PassageModule extends StatelessWidget {
  PassageModule({
    required this.image,
    required this.headImage,
    required this.postInfo,
  });

  final ImageProvider image;
  final ImageProvider headImage;
  final Map<String, dynamic> postInfo;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        Navigator.pushNamed(context, PostScreen.id,arguments: {'image':image,'headImage':headImage,'postInfo':postInfo});
      },
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 6),
        padding: EdgeInsets.all(8.0),
        decoration: BoxDecoration(
          boxShadow: [
            BoxShadow(
              color: Colors.black.withOpacity(0.2),
              // 阴影颜色和透明度
              spreadRadius: 2,
              // 阴影扩展半径
              blurRadius: 5,
              // 阴影模糊半径
              offset: Offset(0, 2), // 阴影偏移量
            ),
          ],
          color: Colors.white,
          borderRadius: BorderRadius.circular(25.0),
        ),
        child: Column(
          children: [
            Text(
              postInfo['title'],
              softWrap: true,
              style: TextStyle(
                color: Colors.black,
                fontSize: 12,
              ),
            ),
            Expanded(
              child: Container(
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: image,
                  ),
                ),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    CircleAvatar(
                      backgroundImage: headImage,
                      radius: 15,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                    Text(postInfo['authorName']),
                  ],
                ),
                Row(
                  children: [
                    Icon(
                      Icons.favorite_rounded,
                      size: 22,
                    ),
                    Baseline(
                      baseline: 18,
                      baselineType: TextBaseline.alphabetic,
                      child: Text(
                        postInfo['likesCount'] < 1000 ? '${postInfo['likesCount']}' : '999+',
                        style: TextStyle(fontSize: 8),
                      ),
                    )
                  ],
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
